using DslModeling = global::Microsoft.VisualStudio.Modeling;
using Microsoft.VisualStudio.Modeling.Validation;

namespace Dslfactory.wcfLanguage
{
 public partial class OperationContract
 {
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="store">Store where new element is to be created.</param>
		/// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
		public OperationContract(DslModeling::Store store, params DslModeling::PropertyAssignment[] propertyAssignments)
			: this(store != null ? store.DefaultPartition : null, propertyAssignments)
		{
		}
		
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="partition">Partition where new element is to be created.</param>
		/// <param name="propertyAssignments">List of domain property id/value pairs to set once the element is created.</param>
  public OperationContract(DslModeling::Partition partition, params DslModeling::PropertyAssignment[] propertyAssignments)
			: base(partition, propertyAssignments)
		{
   IsOperationContract = true;
		}
 }

 [ValidationState(ValidationState.Enabled)]
 public partial class Method
 {
  /// <summary>
  /// Access to signature even when the method was deleted
  /// </summary>
  internal string InternalSignature
  {
   get
   {
    return signaturePropertyStorage;
   }
  }

  /// <summary>
  /// Validation of the fact that if the method is an OperationContract, the interface is a ServiceContract
  /// </summary>
  [ValidationMethod(ValidationCategories.Load|ValidationCategories.Menu|ValidationCategories.Save)]
  private void Validate(ValidationContext context)
  {
   if ((IsOperationContract == true) && (Interface != null) && (Interface.IsServiceContract == false))
    context.LogWarning(string.Format("Method '{0}' is an operation contract whereas interface '{1}' is not a service contract", Signature, Interface.FullName),
                       "001", this);
  }
 }
}
